<template>
	<div class="classCircle">
		<div class="classIndex_h">
			<span>班级圈</span>
		</div>
		<!--  -->
		<div class="classCircle_txt">
			<div><i class="ipm slogn02"></i></div>
			<div>
				<div id="content" class="txt-content emoji-content"></div>
				<span><i>{{textareaLen}}</i>/140</span>
				<p class="txt-error" v-show="!textareaBol">已超过最大长度了</p>
			</div>
			<div class="clear operation-file">
				<!-- 图片上传 -->
				<uploader v-show="selectFileShow" :options="uploadOptions" :autoStart="false" ref="uploader" :file-status-text="statusText" @files-added="filesAdded" @file-removed="fileRemoved" @file-success="fileSuccess" @file-error="fileFail" class="uploader-circle uploader_om">
					<uploader-unsupport></uploader-unsupport>
					<uploader-btn :directory="false" :attrs="attrs" :single="false">
						<img src="../../assets/images/img_icon.png" class="img_icon" title="图片上传">
					</uploader-btn>
					<uploader-list></uploader-list>
				</uploader>
				<!-- 资源上传 -->
				<uploader v-show="selectFileShowRes" :options="uploadOptionsRes" :autoStart="false" ref="uploaderRes" @files-submitted="fileSubmitRes" @file-removed="fileRemovedRes" :file-status-text="statusTextRes" @file-success="fileSuccessRes" @file-error="fileFailRes" class="uploader-add-album uploader_rsd">
					<uploader-unsupport></uploader-unsupport>
					<uploader-btn :directory="false" :single="true" v-show="selectFileBtn">
						<img src="../../assets/images/wenjianjia.png" class="img_icon" title="资源上传">
					</uploader-btn>
					<uploader-list></uploader-list>
				</uploader>
				<!-- 视频上传 -->
				<uploader v-show="selectFileShowVideo" :options="uploadOptionsVideo" :autoStart="true" ref="uploaderVideo" @file-added="fileAddVideo" @files-submitted="fileSubmitVideo" :file-status-text="statusTextVideo" @file-success="fileSuccessVideo" @file-error="fileFailVideo" class="uploader-add-album uploader_rsd">
					<uploader-unsupport></uploader-unsupport>
					<uploader-btn :directory="false" :single="true" :attrs="attrsVideo">
						<img src="../../assets/images/video.png" class="img_icon" title="视频上传">
					</uploader-btn>
					<uploader-list></uploader-list>
				</uploader>
				<i class="i-link box" v-show="linkShowIco" @click="linkURl" title="分享"></i>
				<!--  -->
				<div class="authority_ll fr">
					<template>
						<el-select filterable v-model="authorityChat" placeholder="请选择">
							<el-option label="公开" :value="1"></el-option>
							<el-option label="私密" :value="0"></el-option>
						</el-select>
					</template>
					<el-button type="primary" @click="submitForm()" v-preventReClick>发表</el-button>
				</div>
			</div>
			<div class="thumbnail" v-if="thumbnailList.length != 0">
				<div v-for="(src, index) of thumbnailList" :key="index">
					<img :src="src.url">
					<i class="el-icon-close" @click="closeThumbnail(index, src.id)"></i>
				</div>
			</div>
			<!--  -->
			<div class="thumbnail_red">
				<template v-for="(item, index) of resourceList">
					<div :key="index" v-if="item.video" class="video-close">
						<video width="auto" height="240" controls>
							<source :src="BASE_URL + item.path" type="video/mp4">
							<source :src="BASE_URL + item.path" type="video/ogg">
							<source :src="BASE_URL + item.path">
							您的浏览器不支持 video 标签。
						</video>
						<i class="el-icon-close" @click="closeResource(index)"></i>
					</div>
					<div :key="index" v-else>
						<span>{{item.name}}</span>
						<i class="el-icon-close" @click="closeResource(index)"></i>
					</div>
				</template>
			</div>
			<!--  -->
			<transition name="el-zoom-in-top">
				<div class="i-link-url" v-show="linkShow">
					<div>
						<el-input v-model="linkUrl.name" @change="linkNameValidator" placeholder="请输入链接名称"></el-input>
						<span>{{linkValidator}}</span>
					</div>
					<div>
						<el-input v-model="linkUrl.url" @input="urNamelValidator" placeholder="请输入链接"></el-input>
						<i class="el-icon-back" v-preventReClick @click="submitForm()"></i>
						<span>{{urlValidator}}</span>
					</div>
				</div>
			</transition>
		</div>
		<!--  -->
		<div class="classCircle_test" v-loading="loading">
			<div class="classCircle_title clear">
				<span>班级圈</span>
				<div class="class_private fr">
					<el-radio-group v-model="private_val" @change="getClassGroup">
						<el-radio :label="1">全部</el-radio>
						<el-radio :label="0">只看我的</el-radio>
					</el-radio-group>
				</div>
			</div>
			<ul>
				<li class="classCircle_ls" v-for="(item, index) in classGroupList" :key="item.id" ref='comment2'>
					<div class="classTeest_1 clear">
						<router-link to="###">
							<img :src="BASE_URL + item.avatar_path" v-if="item.avatar_path !== ''">
							<img e-else src="../../../public/images/Group9.png">
						</router-link>
						<div class="classTeest_1r">
							<div class="classTeest_r2 clear">
								<router-link to="###" :title="item.create_name">{{item.create_name}}</router-link>
								<i class="trash_time fr">{{getDateDiff(item.create_time)}}</i>
								<template v-if="private_val == 0">
									<i class="trash_private fr" v-if="item.authority === 1">公开</i>
									<i class="trash_private fr" v-else>私密</i>
								</template>
								<i class="trash fr" v-if="item.create_id == $g.user_id || $store.getters.userInfo.is_headmaster == 1" @click="removeList(item.id)">删除</i>
							</div>
							<!--  -->
							<div class="classTeest_rT" v-html="emoji(item.app_content)"></div>
							<!-- 图片 ， 资源， 视频 -->
							<div class="classTeest_rM" v-if="item.resource.length != 0">
								<template v-for="(list, index2) in item.resource">
									<div class="class-img" v-if="list.file_type === 3">
										<img :src="BASE_URL + list.path" @click="imgPreview(item.resource, list.path)">
									</div>
									<div class="class-video" v-else-if="list.file_type === 6">
										<video width="auto" height="240" controls>
											<source :src="BASE_URL + list.path" type="video/mp4">
											<source :src="BASE_URL + list.path" type="video/ogg">
											<source :src="BASE_URL + list.path">
											您的浏览器不支持 video 标签。
										</video>
									</div>
									<template v-else>
										<div class="classTeest_rM_rsd clear">
											<img :src='`${BASE_URL}/images/format/resourceicon${list.file_type}.png`'>
											<div class="clear">
												<span>{{list.resource_name}}</span>
												<a :href="BASE_URL + '/index/resource/resourcedownload?id='+list.id" download='下载'>下载</a>
											</div>
										</div>
									</template>
								</template>
							</div>
							<!-- 分享 -->
							<template v-for="(url, index3) in item.href">
								<div class="classTeest_link clear">
									<img src='../../assets/images/link-url.png'>
									<div class="clear">
										<a :href="url.href_url" target="_back">{{url.href_name}}</a>
									</div>
								</div>
							</template>
						</div>
						<!--  -->
						<div class="classTeest_rP clear">
							<div class="classTeest_opc fr">
								<span class="class_zan1" v-if="item.is_dianzan != 1" @click="thumbsUp(item.is_dianzan, item.id)">
									<i class="ipm banjiquan_dianzan"></i>
									<em>{{item.dianzan_user.length > 0 ? item.dianzan_user.length : ''}}</em>
								</span>
								<span class="class_zan2" v-else @click="cancel(item.is_dianzan, item.id)">
									<i class="ipm banjiquan_dianzan02"></i>
									<em>{{item.dianzan_user.length > 0 ? item.dianzan_user.length : ''}}</em>
								</span>
								<i class="ipm banjiquan_pinglun" @click="commentBox(index, item.id)"></i>
							</div>
							<div class="classTeest_rZ clear" v-if="item.dianzan_user != ''">
								<template v-for="(list, index) in item.dianzan_user">
									<span><i v-if="index > 0">,</i>{{list.name}}</span>
								</template>
							</div>
						</div>
						<!--回复评论  -->
						<div class="classTeest_rPl">
							<transition name="el-fade-in-linear">
								<div class="classTeest_rTx" v-show="item.showCommentBox">
									<div class="classTeest_rPT">
										<div class="edit-div" ref='comment' :class="`comment_${item.id}`" contenteditable="true" placeholder="友善讨论，互相鼓励，言之有物，互相学习" @paste="noPaste($event)" @input="changeComment(index)"></div>
										<span><i>{{commentLen}}</i>/140</span>
										<p class="txt-error" v-show="!commentBol">已超过最大长度了</p>
									</div>
									<div class="classTeest_rPB clear">
										<div class="emoji_ch box fl">
											<img src="../../assets/images/emojim.png" class="emoji_icon" @click="emojiOFF(2)">
											<vueEmoji @select="selectEmoji2" v-if="showEmoji2" class="selectEmoji"></vueEmoji>
										</div>
										<el-button type="primary" plain @click="removeCommentBox(index)">取消</el-button>
										<el-button type="primary" v-preventReClick @click="getComments(item.id, item.create_id)">发送</el-button>
									</div>
								</div>
							</transition>
							<!-- 评论 -->
							<template>
								<ul v-if="item.comment.length != 0" class="Reply_2">
									<template v-for="(item2, index2) in item.comment">
										<li class="classTeest_PlS" :key="index2" v-if="index2 < 4">
											<div class="classTeest_box clear">
												<router-link to="###">
													<img :src="BASE_URL + item2.avatar_path" v-if="item2.avatar_path !== ''">
													<img e-else src="../../../public/images/Group9.png">
												</router-link>
												<div class="classTeest_reply">
													<div class="classTeest_reply_name clear">
														<span>{{item2.create_name}}</span>
														<template>
															<span v-if=" item2.create_name === item2.receive_name" class="user_Reply"></span>
															<span v-else-if="item2.parent_id > 0" class="user_Reply"><i>回复</i>{{item2.receive_name}}</span>
														</template>
														<strong>{{getDateDiff(item2.create_time)}}</strong>
														<div class="classTeest_opt clear fr">
															<i class="el-icon-delete fr" @click="removeComments(item2.id)" v-if="item2.create_id == $g.user_id"></i>
															<i class="ipm banjiquan_pinglun fr" @click="replyBox(index, index2, item2.id, item2.create_id)" v-if="item2.create_id != $g.user_id"></i>
														</div>
													</div>
													<div class="classTeest_reply_txt" v-html="item2.app_content"></div>
												</div>
											</div>
											<transition name="el-fade-in-linear">
												<div class="classTeest_rTx" v-show="item2.showCommentBox">
													<div class="classTeest_rPT">
														<div class="edit-div" :class="`active_${item2.id}`" :data-index='item2.id' contenteditable="true" ref="asd" placeholder="友善讨论，互相鼓励，言之有物，互相学习.." @paste="noPaste($event)" @input="changeComment2(index2)"></div>
														<span><i>{{commentLen2}}</i>/140</span>
														<p class="txt-error" v-show="!commentBol2">已超过最大长度了</p>
													</div>
													<div class="classTeest_rPB clear">
														<div class="emoji_ch box fl">
															<img src="../../assets/images/emojim.png" class="emoji_icon" @click="emojiOFF(3)">
															<vueEmoji @select="selectEmoji3" v-if="showEmoji3" class="selectEmoji"></vueEmoji>
														</div>
														<el-button type="primary" plain @click="removeReplyBox(index, index2)">取消</el-button>
														<el-button type="primary" v-preventReClick @click="replyComments(item2.class_group_id)">发送</el-button>
													</div>
												</div>
											</transition>
										</li>
										<template v-if="item.moreBol">
											<li class="classTeest_PlS" :key="index2" v-if="index2 >= 4">
												<div class="classTeest_box clear">
													<router-link to="###">
														<img :src="BASE_URL + item2.avatar_path" v-if="item2.avatar_path !== ''">
														<img e-else src="../../../public/images/Group9.png">
													</router-link>
													<div class="classTeest_reply">
														<div class="classTeest_reply_name clear">
															<span>{{item2.create_name}}</span>
															<template>
																<span v-if=" item2.create_name === item2.receive_name" class="user_Reply"></span>
																<span v-else-if="item2.parent_id > 0" class="user_Reply"><i>回复1</i>{{item2.receive_name}}</span>
															</template>
															<strong>{{getDateDiff(item2.create_time)}}</strong>
															<div class="classTeest_opt clear fr">
																<i class="el-icon-delete fr" @click="removeComments(item2.id)" v-if="item2.create_id == $g.user_id"></i>
																<i class="ipm banjiquan_pinglun fr" @click="replyBox(index, index2, item2.id, item2.create_id)" v-if="item2.create_id != $g.user_id"></i>
															</div>
														</div>
														<div class="classTeest_reply_txt" v-html="item2.app_content"></div>
													</div>
												</div>
												<transition name="el-fade-in-linear">
													<div class="classTeest_rTx" v-show="item2.showCommentBox">
														<div class="classTeest_rPT">
															<div class="edit-div" :class="`active_${item2.id}`" :data-index='item2.id' contenteditable="true" @paste="noPaste($event)" ref="asd" placeholder="友善讨论，互相鼓励，言之有物，互相学习.." @input="changeComment2(index2)"></div>
															<span><i>{{commentLen2}}</i>/140</span>
															<p class="txt-error" v-show="!commentBol2">已超过最大长度了</p>
														</div>
														<div class="classTeest_rPB clear">
															<div class="emoji_ch box fl">
																<img src="../../assets/images/emojim.png" class="emoji_icon" @click="emojiOFF(3)">
																<vueEmoji @select="selectEmoji3" v-if="showEmoji3" class="selectEmoji"></vueEmoji>
															</div>
															<el-button type="primary" plain @click="removeReplyBox(index, index2)">取消</el-button>
															<el-button type="primary" v-preventReClick @click="replyComments(item2.class_group_id)">发送</el-button>
														</div>
													</div>
												</transition>
											</li>
										</template>
									</template>
									<template v-if="!item.moreBol">
										<li class="Reply_2-more" v-if="item.comment.length > 4" @click="commentMoreBol(index)">
											<span>更多{{item.comment.length - 4}}条回复,</span>
											<span>展开更多 <i class="el-icon-arrow-up"></i></span>
										</li>
									</template>
									<template v-else>
										<li class="Reply_2-more" v-if="item.comment.length > 4" @click="commentMoreBol(index)">
											<span></span>
											<span>收起 <i class="el-icon-arrow-up arrow-up"></i></span>
										</li>
									</template>
								</ul>
								<!--  -->
							</template>
						</div>
					</div>
				</li>
			</ul>
			<div class="pageBox" v-if="total_number > page_size">
				<el-pagination @current-change="change_page" :page-size="page_size" :current-page="page_index" layout="prev, pager, next" :total="total_number">
				</el-pagination>
			</div>
			<div class="dependent" v-if="placeholder">
				<i class="ipm image_nofound"></i>
				<p>还没发现任何相关的内容哦~</p>
			</div>
		</div>
		<!-- 预览图片 -->
		<image-viewer v-if="imagePreview.showViewer" :initial-index="imageIndex" :on-close="closeViewer" :url-list="imagePreview.previewSrcList">
		</image-viewer>
	</div>
</template>
<script>
	import E from 'wangeditor'; 
	import emotions from '../../../public/emotions.json';
	import vueEmoji from './emoji'

	let btnmenu = [
	   // 'bold',//粗体
	   // 'fontSize',//字号
	   // 'fontName',//字体
	   // 'italic',//斜体
	   // 'undeline',//下划线
	   // 'justify',//对齐方式
	   'emoticon',//表情
	   'quote',//引用
	   'link',//插入链接
	  // 'strikeThrough',//删除线
	  'undo', //撤销
	  'redo', // 重复
	   ]
	export default{
		components: {
		    vueEmoji
		},
		name: '',
		props: ['classValue'],
		data(){
			return {
				imagePreview: {/*图片预览*/
					showViewer: false,
					previewSrcList: []
				},
				classGroupList: [],
				textarea: '',//发表
				commentVal: '',
				commentIndex: '',
				commentIndex2: '',
				commentVal2: '',
				comment_id: '', //回复评论id
				create_id: '', //回复评论create_id
				parent_id: '', //回复评论parent_id
				picture:[],

				statusText: {
			      	success: '上传成功',  
			      	error: '上传出错',  
			     	uploading: '正在上传...',  
			      	paused: '暂停',  
			      	waiting: '等待上传'  
				},
				selectFileOrNot:false,  //是否选中文件
			    uploadInfo:{
					file_name:'',
					file_path:'',
					file_size:0
				},
				attrs: {
			      	accept: ['image/*']
			    },

		    	uploadOptions: {
			          target: this.BASE_URL+'/api/resource/res_upload',
			          testChunks: false,
			          headers:{Authorization : `Bearer `+this.$g.access_token},
			    },
	      		selectFileShow:true,//是否显示选择文件按钮
				uploadRetryTimes:100,//文件最大重传次数
				uploaderNumber:0,

				loading: false,
				placeholder: true,
				path: this.$route.query.id,

				page_index: 1,
				page_size: this.$g.page_size,
				total_number: 0,
				thumbnailList: [],

				authorityChat: 1,
				private_val: 1,
				showEmoji: false,
				showEmoji2: false,
				showEmoji3: false,

				resourceList: [],
				statusTextRes: {
				    success: '上传成功',  
				    error: '上传出错',  
				    uploading: '正在上传...',  
				    paused: '暂停',  
				    waiting: '等待上传'  
				},
				attrsRes: {
				    accept: 'video/*'
				},

				uploadOptionsRes: {
				      target: this.BASE_URL+'/api/resource/res_upload',
				      testChunks: false,
				      headers:{Authorization : `Bearer `+this.$g.access_token},
				},
				selectFileShowRes:true,//是否显示选择文件按钮
				uploadRetryTimesRes:100,//文件最大重传次数,

				linkUrl:{
					name: '',
					url: ''
				},
				linkValidator: '',
				urlValidator: '',
				linkShow: false,
				linkShowIco: true,

				statusTextVideo: {
				    success: '上传成功',  
				    error: '上传出错',  
				    uploading: '正在上传...',  
				    paused: '暂停',  
				    waiting: '等待上传'  
				},
				attrsVideo: {
				    accept: ['video/*']
				},

				uploadOptionsVideo: {
				      target: this.BASE_URL+'/api/resource/res_upload',
				      testChunks: false,
				      headers:{Authorization : `Bearer `+this.$g.access_token},
				},
				selectFileShowVideo:true,//是否显示选择文件按钮
				uploadRetryTimesVideo:100,//文件最大重传次数,
				fileNumber: 0,
				uploadNumber:0,
				selectFileBtn: true,
				moreBol: false,

				textareaLen: 0,
				textareaBol: true,
				commentLen: 0,
				commentBol: true,
				commentLen2: 0,
				commentBol2: true,
				editor: null,
				txtLength: 140,
				imgIndex: '',
				uploadLimitMax: 0,
			}
		},
		created(){
			this.getVideoUpLimit()
		},
		computed: {
			imageIndex() {
			    return this.imagePreview.previewSrcList.indexOf(this.imgIndex);
			}

		},
		mounted(){

			this.$nextTick(function () {
			    if( typeof(this.$route.query.id) !== 'undefined' && parseInt(this.$route.query.id) > 0 ){
					this.getClassGroup()
				} 

		   		this.editor = new E('#content');

				// 自定义菜单配置
				this.editor.customConfig.menus = btnmenu;
				// 设置超时
				this.editor.customConfig.uploadImgTimeout=3*60*1000;
				// 关闭粘贴样式的过滤
				this.editor.customConfig.pasteFilterStyle = false;
				// 忽略粘贴内容中的图片
				this.editor.customConfig.pasteIgnoreImg = true;
				this.editor.customConfig.onfocus = ()=>{
					// if (this.editor.txt.html() === '<p class="e-placeholder">写点什么···</p>') {
					// 	this.editor.txt.html('') 
					// }
				}

				this.editor.customConfig.onblur = (html)=>{}
				this.editor.customConfig.onchange = (html) => {
					let tmp_lenth = this.txtLength
					let txt = this.editor.txt.text()
					var imgReg = /<img.*?(?:>|\/>)/gi;
					var arr = html.match(imgReg);
					var arr_length = arr ? arr.length : 0;
					var tmp_html = html;
					if (txt.length + arr_length > tmp_lenth) {
						var temp_str = '';
						var new_arr = [];
						if (arr_length > 0) {
							for (var i = 0; i < arr.length; i++) {
								var temp_item = tmp_html.substr(0, tmp_html.indexOf(arr[i]));
								new_arr.push(temp_item);
								tmp_html = tmp_html.substr(tmp_html.indexOf(arr[i]) + arr[i].length);	
							}

							new_arr.push(tmp_html);
							// console.log(arr, arr.length, 'n:',new_arr);
							var temp_lengths = 0;
							
							for (var i = 0; i < new_arr.length; i++) {
								var tmp_str1 = this.ToText(new_arr[i])
								var tmp_length1 = tmp_str1.length
								// console.log('L:',temp_lengths, tmp_length1);
								if (temp_lengths + tmp_length1 <= tmp_lenth) {
									temp_str += new_arr[i];
									temp_lengths += tmp_length1;
								} else {
									var l_length = tmp_lenth - temp_lengths;
									// console.log('4:',tmp_lenth,temp_lengths,l_length);
									if (l_length > 0) {
										var temp_item = tmp_str1.substr(0, l_length)
										// var 
										temp_str += new_arr[i].substr(0, new_arr[i].indexOf(temp_item) + temp_item.length);
										temp_lengths += l_length;
										// console.log('a:',new_arr[i],new_arr[i].indexOf(temp_item));
									} else {
										temp_lengths += l_length;
									}
								}
								// console.log('www:', temp_lengths);
								if (arr[i] && temp_lengths < tmp_lenth) {
									temp_str += arr[i];
									temp_lengths += 1;
								}
								// console.log('S:',temp_str)
							}
							// console.log(333, temp_str);
							html = temp_str;
							this.textareaLen = tmp_lenth
							this.editor.txt.html(html)
						} else {

							var temp_item = this.editor.txt.text().substr(0, tmp_lenth);
							// console.log('s:', temp_item);
							temp_str = html.substr(0, html.indexOf(temp_item) + temp_item.length);
							html = temp_str;
							this.textareaLen = tmp_lenth
							this.editor.txt.html(html)
						}

						
					}else{
						html = this.editor.txt.html()
					}
					this.textarea = html
				}
				// 表情面板可以有多个 tab ，因此要配置成一个数组。数组每个元素代表一个 tab 的配置
				this.editor.customConfig.emotions = [
					{
						// tab 的标题
						title: '默认',
						type: 'image',
						content: emotions
					}
				]
				this.editor.create();

				let titleArr= ['表情', '引用', '链接', '删除线', '撤销', '恢复']
				let iconArr = document.querySelectorAll('.w-e-menu i')
				iconArr.forEach((item, index)=>{
					item.parentNode.setAttribute('title', titleArr[index])
				})

			 })
		},	
		watch:{
			'$route' (to, from) {
				if( typeof(to.query.id) !== 'undefined' && parseInt(to.query.id) > 0 ){
					this.path = this.$route.query.id;
					this.getClassGroup()
				} 
			},
			'thumbnailList'(val, newval){

				val.length > 0 ? this.selectFileShowRes = false : this.selectFileShowRes = true;
				val.length >= 1 ? this.selectFileShowVideo = false : this.selectFileShowVideo = true;
				val.length >= 1 ? this.linkShowIco = false : this.linkShowIco = true
			},
			'resourceList'(val, newval){
				newval.length > 0 ? this.selectFileShow = false : this.selectFileShow = true;
				newval.length >= 1 ? this.selectFileShowRes = false : this.selectFileShowRes = true;
				newval.length >= 1 ? this.linkShowIco = false : this.linkShowIco = true
				newval.length >= 1 ? this.selectFileShowVideo = false : this.selectFileShowVideo = true;
			},
			'linkShow'(val,newval){
				if (val === true) {
					this.selectFileShow = false;
					this.selectFileShowRes = false;
					this.selectFileShowVideo = false
				}else{
					this.selectFileShow = true;
					this.selectFileShowRes = true;
					this.selectFileShowVideo = true
				}
			},
			'uploadNumber':{
				handler(newVal,oldVal){

					if( newVal === this.fileNumber && this.fileNumber != 0){
						this.saveClassGroup();
					}
				}
			},
			'textarea'(to, from){

				let img = document.querySelectorAll('#textareaVal > img').length
				let len = to.replace(/<[^>]+>/g,"").length;
				let sum = parseInt(img )+ parseInt(len)
				this.textareaLen = sum
				if (this.textareaLen > 140) {
					this.textareaBol = false
					return
				}else{
					this.textareaBol = true
				}
			},
			'commentVal'(to, from){
				let img = this.commentIndex.getElementsByTagName('img').length;
				let len = to.replace(/<[^>]+>/g,"").length;
				let sum = parseInt(img )+ parseInt(len)
				this.commentLen = sum;
				this.changeComment()
				if (this.commentLen > 140) {
					this.commentBol = false
					return
				}else{
					this.commentBol = true
				}
			},
			'commentVal2'(to, from){
				let img = this.commentIndex2.getElementsByTagName('img').length;
				let len = to.replace(/<[^>]+>/g,"").length;
				let sum = parseInt(img )+ parseInt(len)
				this.commentLen2 = sum;
				this.changeComment2()
				if (this.commentLen2 > 140) {
					this.commentBol2 = false
					return
				}else{
					this.commentBol2 = true
				}
			}
		},
		methods: {

			getVideoUpLimit() {
				let success = (data => {
					this.uploadLimitMax = parseFloat(data.data.upload_setting.teacher_max_size);
				})
				this.$ajax.get('api/video/video_setting', { params: {}, func: { success: success } })
			},
			/**
			 * 关闭图片
			 * @DateTime 2020-04-16T17:40:41+0800
			 * @qiu_m
			 * @return   {[type]}                 [description]
			 */
			 closeViewer() {
			 	this.imagePreview.showViewer = false;
			 	this.imagePreview.previewSrcList = []
			 },
			ToText(HTML){
				var input = HTML;
				return input.replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi,'').replace(/<[^>]+?>/g,'').replace(/\s+/g,' ').replace(/ /g,' ').replace(/>/g,' ');  
			},
			// 禁止富文本粘贴图片
			noPaste(e){
				e.preventDefault();
				var text = null;
				
				if(window.clipboardData && clipboardData.setData) {
				    // IE
				    text = window.clipboardData.getData('text');
				} else {
				    text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在这里输入文本');
				}
				if (document.body.createTextRange) {    
				    if (document.selection) {
				        textRange = document.selection.createRange();
				    } else if (window.getSelection) {
				        sel = window.getSelection();
				        var range = sel.getRangeAt(0);
				        
				        // 创建临时元素，使得TextRange可以移动到正确的位置
				        var tempEl = document.createElement("span");
				        tempEl.innerHTML = "&#FEFF;";
				        range.deleteContents();
				        range.insertNode(tempEl);
				        textRange = document.body.createTextRange();
				        textRange.moveToElementText(tempEl);
				        tempEl.parentNode.removeChild(tempEl);
				    }
				    textRange.text = text;
				    textRange.collapse(false);
				    textRange.select();
				} else {
				    // Chrome之类浏览器
				    document.execCommand("insertText", false, text);
				}
			},
			/*
				加载更多评论
			*/
			commentMoreBol(index){
				this.classGroupList[index].moreBol = !this.classGroupList[index].moreBol;
			},
			keepLastIndex(obj) {

				  if (window.getSelection) { //ie11 10 9 ff safari
				   obj.focus(); //解决ff不获取焦点无法定位问题
				   var range = window.getSelection(); //创建range
				   range.selectAllChildren(obj); //range 选择obj下所有子内容
				   range.collapseToEnd(); //光标移至最后
				  } else if (document.selection) { //ie10 9 8 7 6 5
				   var range = document.selection.createRange(); //创建选择对象
				   //var range = document.body.createTextRange();
				   range.moveToElementText(obj); //range定位到obj
				   range.collapse(false); //光标移至最后
				   range.select();
				}
			},
			/*
				评论他人的班级圈
			*/
			changeComment(){
				let tmp_lenth = 140
				let txt = this.commentIndex.textContent
				var imgReg = /<img.*?(?:>|\/>)/gi;
				var arr = this.commentIndex.innerHTML.match(imgReg);
				var arr_length = arr ? arr.length : 0;
				var tmp_html = this.commentIndex.innerHTML;
				if (txt.length + arr_length > tmp_lenth) {
					var temp_str = '';
					var new_arr = [];
					if (arr_length > 0) {
						for (var i = 0; i < arr.length; i++) {
							var temp_item = tmp_html.substr(0, tmp_html.indexOf(arr[i]));
							new_arr.push(temp_item);
							tmp_html = tmp_html.substr(tmp_html.indexOf(arr[i]) + arr[i].length);	
						}

						new_arr.push(tmp_html);
						// console.log(arr, arr.length, 'n:',new_arr);
						var temp_lengths = 0;
						
						for (var i = 0; i < new_arr.length; i++) {
							var tmp_str1 = this.ToText(new_arr[i])
							var tmp_length1 = tmp_str1.length
							// console.log('L:',temp_lengths, tmp_length1);
							if (temp_lengths + tmp_length1 <= tmp_lenth) {
								temp_str += new_arr[i];
								temp_lengths += tmp_length1;
							} else {
								var l_length = tmp_lenth - temp_lengths;
								// console.log('4:',tmp_lenth,temp_lengths,l_length);
								if (l_length > 0) {
									var temp_item = tmp_str1.substr(0, l_length)
									// var 
									temp_str += new_arr[i].substr(0, new_arr[i].indexOf(temp_item) + temp_item.length);
									temp_lengths += l_length;
									// console.log('a:',new_arr[i],new_arr[i].indexOf(temp_item));
								} else {
									temp_lengths += l_length;
								}
							}
							// console.log('www:', temp_lengths);
							if (arr[i] && temp_lengths < tmp_lenth) {
								temp_str += arr[i];
								temp_lengths += 1;
							}
							// console.log('S:',temp_str)
						}
						// console.log(333, temp_str);
						this.commentIndex.innerHTML = temp_str;
						this.textareaLen2 = tmp_lenth
						this.commentVal = this.commentIndex.innerHTML 
					} else {

						var temp_item = this.commentIndex.textContent.substr(0, tmp_lenth);
						// console.log('s:', temp_item);
						temp_str = this.commentIndex.innerHTML.substr(0, this.commentIndex.innerHTML.indexOf(temp_item) + temp_item.length);
						this.commentIndex.innerHTML = temp_str;

						this.textareaLen2 = tmp_lenth

						this.commentVal = this.commentIndex.innerHTML 
						// tmp_str1.substr(0, l_length)
					}
				
					// console.log(1,new_arr)
					
				}else{

					this.textareaLen2 = (txt.length + arr_length)
					this.commentVal = this.commentIndex.innerHTML 
				}
				// this.commentVal = this.commentIndex.innerHTML; 
				setTimeout(()=>{
				 this.keepLastIndex(this.commentIndex)
				},5)
				
			},
			/*
				回复他人的班级圈
			*/
			changeComment2(){
				let tmp_lenth = 140
				let txt = this.commentIndex2.textContent
				var imgReg = /<img.*?(?:>|\/>)/gi;
				var arr = this.commentIndex2.innerHTML.match(imgReg);
				var arr_length = arr ? arr.length : 0;
				var tmp_html = this.commentIndex2.innerHTML;
				if (txt.length + arr_length > tmp_lenth) {
					var temp_str = '';
					var new_arr = [];
					if (arr_length > 0) {
						for (var i = 0; i < arr.length; i++) {
							var temp_item = tmp_html.substr(0, tmp_html.indexOf(arr[i]));
							new_arr.push(temp_item);
							tmp_html = tmp_html.substr(tmp_html.indexOf(arr[i]) + arr[i].length);	
						}

						new_arr.push(tmp_html);
						// console.log(arr, arr.length, 'n:',new_arr);
						var temp_lengths = 0;
						
						for (var i = 0; i < new_arr.length; i++) {
							var tmp_str1 = this.ToText(new_arr[i])
							var tmp_length1 = tmp_str1.length
							// console.log('L:',temp_lengths, tmp_length1);
							if (temp_lengths + tmp_length1 <= tmp_lenth) {
								temp_str += new_arr[i];
								temp_lengths += tmp_length1;
							} else {
								var l_length = tmp_lenth - temp_lengths;
								// console.log('4:',tmp_lenth,temp_lengths,l_length);
								if (l_length > 0) {
									var temp_item = tmp_str1.substr(0, l_length)
									// var 
									temp_str += new_arr[i].substr(0, new_arr[i].indexOf(temp_item) + temp_item.length);
									temp_lengths += l_length;
									// console.log('a:',new_arr[i],new_arr[i].indexOf(temp_item));
								} else {
									temp_lengths += l_length;
								}
							}
							// console.log('www:', temp_lengths);
							if (arr[i] && temp_lengths < tmp_lenth) {
								temp_str += arr[i];
								temp_lengths += 1;
							}
							// console.log('S:',temp_str)
						}
						// console.log(333, temp_str);
						this.commentIndex2.innerHTML = temp_str;
						// this.textareaLen2 = tmp_lenth
						this.commentVal2 = this.commentIndex2.innerHTML 
					} else {

						var temp_item = this.commentIndex2.textContent.substr(0, tmp_lenth);
						// console.log('s:', temp_item);
						temp_str = this.commentIndex2.innerHTML.substr(0, this.commentIndex2.innerHTML.indexOf(temp_item) + temp_item.length);
						this.commentIndex2.innerHTML = temp_str;

						// this.textareaLen2 = tmp_lenth

						this.commentVal2 = this.commentIndex2.innerHTML 
						// tmp_str1.substr(0, l_length)
					}
				
					// console.log(1,new_arr)
					
				}else{

					// this.textareaLen2 = (txt.length + arr_length)
					this.commentVal2 = this.commentIndex2.innerHTML 
				}
				// this.commentVal = this.commentIndex2.innerHTML; 
				setTimeout(()=>{
				 this.keepLastIndex(this.commentIndex2)
				},5)
				
			},
			/*
				发表班级圈信息
			*/
			changeText(){
				this.textarea = this.$refs.textarea.innerHTML; 
			},
			/*
				班级圈表情
			*/
			selectEmoji (code) {
				this.showEmoji = false
				this.textarea = this.$refs.textarea.innerHTML = this.emoji(this.$refs.textarea.innerHTML + code);
			},
			/*
				班级圈表情
			*/
			selectEmoji2 (code) {
				this.showEmoji2 = false
				this.commentVal = this.commentIndex.innerHTML = this.emoji(this.commentIndex.innerHTML + code)
			},
			selectEmoji3 (code) {
				this.showEmoji3 = false
				this.commentVal2 = this.commentIndex2.innerHTML = this.emoji(this.commentIndex2.innerHTML + code)

			},
			linkURl(){
				this.linkShow = !this.linkShow
			},
			linkNameValidator(val){
				if (is_empty(val)) {
					return  this.linkValidator = '请输入链接名称';
				}else{
					return this.linkValidator = ''
				}
			},
			urNamelValidator(val){

				var pattern = /^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/;
				if (is_empty(val)) {
					return  this.urlValidator = '链接不能为空';
				}else if(!pattern.test(val)){
					return  this.urlValidator = '请输入正确的链接';

				}else{
					return  this.urlValidator = ''
				}

			},
			emojiOFF(num){

				switch(num){
					case 1:
						this.showEmoji = !this.showEmoji;
						break;
					case 2:
						this.showEmoji2 = !this.showEmoji2;
						break;
					case 3:
						this.showEmoji3 = !this.showEmoji3;
						break;
				}
			},
			getDateTimeStamp (dateStr) {
			    return Date.parse(dateStr.replace(/-/gi,"/"));
			},
			getDateDiff (dateStr) {
			    var publishTime = this.getDateTimeStamp(dateStr)/1000,
			        Dseconds,
			        Dminutes,
			        Dhours,
			        Ddays,
			        timeNow = parseInt(new Date().getTime()/1000),
			        d,

			        date = new Date(publishTime*1000),
			        Y = date.getFullYear(),
			        M = date.getMonth() + 1,
			        D = date.getDate(),
			        H = date.getHours(),
			        m = date.getMinutes(),
			        s = date.getSeconds();
			        //小于10的在前面补0
			        if (M < 10) {
			            M = '0' + M;
			        }
			        if (D < 10) {
			            D = '0' + D;
			        }
			        if (H < 10) {
			            H = '0' + H;
			        }
			        if (m < 10) {
			            m = '0' + m;
			        }
			        if (s < 10) {
			            s = '0' + s;
			        }

			    d = timeNow - publishTime;
			    Ddays = parseInt(d/86400);
			    Dhours = parseInt(d/3600);
			    Dminutes = parseInt(d/60);
			    Dseconds = parseInt(d);

			    if(Ddays > 0 && Ddays < 3){
			          return M + '-' + D + ' ' + H + ':' + m;
			    }else if(Ddays <= 0 && Dhours > 0){
			       return '昨天'+ ' ' + H + ':' + m;
			    }else if(Dhours <= 0 && Dminutes > 0){
			         return H + ':' + m;
			    }else if (Dseconds < 60) {
			    	return '刚刚';
			        if (Dseconds <= 0) {
			        	 return '';
			        }else {
			        	   return '';
			        }
			    }else if (Ddays >= 3 && Ddays < 30){
			        return M + '-' + D + ' ' + H + ':' + m;
			    }else if (Ddays >= 30) {
			        // return Y + '-' + M + '-' + D + ' ' + H + ':' + m;
			        return M + '-' + D + ' ' + H + ':' + m;
			    }
			},
			/**
			 * 删除预览的图片
			 * @DateTime 2020-05-29T14:05:32+0800
			 * @qiu_m
			 * @param    {[type]}                 index [description]
			 * @param    {[type]}                 id    [description]
			 * @return   {[type]}                       [description]
			 */
			closeThumbnail(index, id){

				this.$refs.uploader.uploader.removeFile(this.$refs.uploader.uploader.fileList.find(item=>item._lastProgressCallback == id))
				this.thumbnailList.splice(index, 1)

			},
			/**
			 * 图片预览
			 * @DateTime 2020-05-28T09:16:28+0800
			 * @qiu_m
			 * @param    {[type]}                 resource [description]
			 * @return   {[type]}                          [description]
			 */
			imgPreview(resource, path){
				this.imgIndex = this.BASE_URL +path
				this.imagePreview.showViewer = true
				let imgArr = resource.map(item=>this.BASE_URL +item.path)
				this.imagePreview.previewSrcList.push(...imgArr)
			},
			submitForm(){

				if (!this.textareaBol) {
					return this.$message.warning('已超过最大长度了...')
				}

				let imgArr = document.querySelectorAll('.w-e-text img')
				let len = this.editor.txt.text().replace(/&nbsp;/g, '').replace(/^\s+|\s+$/g, '')
				if (imgArr.length == 0 &&  len.length ==  0 ) {
					return this.$message.warning('输入框不能为空');
				}
	
				if (this.linkShow === true) {
					if (is_empty(this.linkUrl.name)  || is_empty(this.linkUrl.url) ) {
						return this.$message.error('请输入要分享的内容');
					}

					var pattern = /^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/;
					if (is_empty(this.linkUrl.url)) {
						return this.$message.error('链接不能为空');
					}else if(!pattern.test(this.linkUrl.url)){
						return this.$message.error('请输入正确的链接');
					}
				}

				this.fileNumber =  this.$refs.uploader.uploader.fileList.length +  this.$refs.uploaderRes.uploader.fileList.length 

				if( this.fileNumber > 0 ){

					if( this.$refs.uploader.uploader.fileList.length > 0 ){
						this.fileUpload();
					}else if( this.$refs.uploaderRes.uploader.fileList.length > 0 ){
						this.fileUploadRes();
					}

				}else{
					this.showEmoji = false
					this.saveClassGroup();
				}
			},
			//发表提交
			saveClassGroup(){

				this.picture.push.apply(this.picture, this.resourceList)
				let success = (res =>{
					this.$message.success(res.msg);
					this.textarea = '';
					this.$refs.uploader.uploader.cancel();
					this.$refs.uploaderVideo.uploader.cancel();
					this.$refs.uploaderRes.uploader.cancel();
					
					this.picture = [];
					this.resourceList = [];
					this.thumbnailList = [];
					this.linkUrl.url = '';
					this.linkUrl.name = '';
					this.linkShow = false;
					this.uploadNumber = 0;
					this.editor.txt.html('')
					this.textarea = ''
					this.getClassGroup();
				});

				let fail = (res=>{})

				let params = {
						content: this.textarea,
						class_id: this.$route.query.id,
						picture:  this.picture,
						create_id: this.$g.user_id,
						authority: this.authorityChat,
						href_url: this.linkUrl.url,
						href_name: this.linkUrl.name
				};
				this.$ajax.post('api/org/class_group',params,{func:{success:success, fail: fail}})
			},
			//列表
			getClassGroup(){
				this.loading = true;

				let params =  {
						class_id: this.path,
						userid: this.$g.user_id,
						page_index: this.page_index,
						page_size: this.page_size,
						authority: this.private_val,
						have_tree: 1
					}

				if (this.private_val == 1) {
				    params = Object.assign({}, params, {})
				}else if (this.private_val == 0) {
				    params = Object.assign({}, params, {create_id: this.$g.user_id,})
				}

				let success = (res=>{
					let data = res.data;
					this.classGroupList = data.data;

					this.loading = false;
					this.total_number = data.data_sum
					this.page_index = parseInt(data.page_index)

					this.thumbnailList = []
					this.resourceList = []
					this.$forceUpdate();
					this.classGroupList.length === 0
					? this.placeholder = true
					: this.placeholder = false
				})
				this.$ajax({
					url: 'api/org/class_group',
					method: 'get',
					params: params,
					func: {success: success}
				})
			},
			change_page(val){
				this.page_index = val;
				this.getClassGroup()
			},
			//评论框
			commentBox(index, id){

				let className = 'comment_'+id;
				this.commentIndex = document.getElementsByClassName(className)[0]
				this.classGroupList[index].showCommentBox = !this.classGroupList[index].showCommentBox;	

			},
			removeCommentBox(index){
				this.classGroupList[index].showCommentBox = false;
			},
			//回复--评论
			replyBox(index, index2, id, create_id ){

				let className = 'active_'+id;
				this.commentIndex2 = document.getElementsByClassName(className)[0]

				this.classGroupList[index].comment[index2].showCommentBox = !this.classGroupList[index].comment[index2].showCommentBox;
				this.comment_id = id
				this.create_id = create_id
				
			},
			removeReplyBox(index, index2){
				this.classGroupList[index].comment[index2].showCommentBox = false;
			},
			//点赞
			thumbsUp(bol, id){
				let number = parseInt(bol)
				if (number === 1) {
					this.$message({message: '你已经点过赞啦~~~',type: 'success'});
				}else{
				
					let success = (res=>{
						this.getClassGroup()
						// this.$message({message: '赞啦~~~',type: 'success'});
					})
					this.$ajax({
						url: 'api/org/dianzan',
						method: 'post',
						data: {
							class_group_id: id,
							userid: this.$g.user_id
						},
						func: {
							success: success
						}
					})
				}
			},
			cancel(bol, id){
				let number = parseInt(bol)
				if (number === 1) {
					let success = (res=>{
						this.getClassGroup()
					})
					this.$ajax({
						url: 'api/org/dianzan',
						method: 'delete',
						params: {
							class_group_id: id,
							userid: this.$g.user_id
						},
						func: {success: success}
					})
				}else{
					this.$message.success('你已经点过赞啦~~~');
				}
			},
			//回复评论
			getComments(res_id, create_id){
				if (!this.commentBol) {
					this.$message.warning('已超过最大长度了...');
					return
				}

				if (this.commentVal == '') {
					this.$message.error('评论不能为空哦~');
					return
				}
				let success = (res=>{
					this.commentVal = ''
					this.commentIndex.innerHTML = '';
					this.$message.success(res.msg);
					this.getClassGroup()
				})
				this.$ajax({
					url: 'api/org/class_group_comment',
					method: 'post',
					data: {
						content: this.commentVal,
						class_group_id: res_id,
						create_id: this.$g.user_id,
						parent_id: 0,
						receive_id: create_id
					},
					func: {success: success}
				})
			},
			//回复评论
			replyComments(res_id){

				if (!this.commentBol2) {
					this.$message.warning('已超过最大长度了...');
					return
				}

				if (this.commentVal2 == '') {
					this.$message.error('回复不能为空哦~');
					return
				}
				let success = (res=>{
					this.$message.success(res.msg);
					this.commentVal2 = ''
					this.commentIndex2.innerHTML = '';
					this.getClassGroup()
				})
				this.$ajax({
					url: 'api/org/class_group_comment',
					method: 'post',
					data: {
						content: this.commentVal2,
						class_group_id: res_id,
						create_id: this.$g.user_id,
						parent_id: this.comment_id,
						receive_id: this.create_id
					},
					func: {success: success}
				})
			},
			//删除列表
			removeList(res_id){
				this.$confirm('确认删除吗?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning',
					customClass: 'confirm-them',
				}).then(() => {
					let success = (res=>{
						this.$message.success(res.msg);
						this.getClassGroup()
					})
					this.$ajax({
						url: 'api/org/class_group',
						method: 'put',
						data: {
							id: res_id,status: 0,
						},
						func: {success: success}
					})
				}).catch(() => {});
			},
			//删除评论
			removeComments(res_id){
				this.$confirm('你确定要删除评论吗，删除将不能恢复?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning',
					customClass: 'confirm-them',
				}).then(() => {
					let success = (res=>{
						this.$message.success(res.msg);
						this.getClassGroup()
					})
					this.$ajax({
						url: 'api/org/class_group_comment',
						method: 'delete',
						params: {
							id: res_id,status: 0,
						},
						func: {success: success}
					})
				}).catch(() => {});
			},
			//上传成功的事件  
			fileSuccess (rootFile, file, message, chunk) { 
				this.$refs.uploaderRes.uploader.cancel();
				this.uploadNumber++;
				var mess = JSON.parse(message);
					mess = handleResponseData(mess)
			 	if(parseInt( mess.data.status ) ===1 ){
			 		this.uploaderNumber++
			 		this.picture.push( {
			 			path:mess.data.file_path,
			 			name:mess.data.file_name,
			 			postfix:mess.data.post_fix,
			 		} );
			 	} else if (mess.status === 'fail') {
			 		this.$message.error(mess.msg + ' ' + file.name)
			 		this.$refs.uploader.uploader.cancel()
			 	}
			},
			fileFail( rootFile, file, message, chunk ){
				// console.info(rootFile, file, message, chunk)
				var mess = JSON.parse(message);
				if( parseInt( mess.error ) === 401 && this.uploadRetryTimes > 0){
					let callbcak = ( data=>{
						this.uploadRetryTimes--;
						this.$refs.uploader.uploader.retry( file );
	            	})
					this.get_access_token( callbcak );
				}else{
					this.$message.error(mess.msg);
				}
			},
			filesAdded( files,fileList ){

				let url = []
				let img = null
				let obj = []
				this.thumbnailList = []

				let filearr = this.$refs.uploader.uploader.fileList;

				if (filearr.length > 9){;
					for (var i = filearr.length - 1; i >= 0; i--) {
						i > 8 &&  this.$refs.uploader.uploader.removeFile( filearr[i] )
					}
				}

				url  =  filearr
				url.forEach(item=>{
					item.fileType = 'image/png'
					item.name = item.name.replace(/\.\w+$/, '.png')
					item.relativePath = item.relativePath.replace(/\.\w+$/, '.png')
					img =  window.URL.createObjectURL(item.file)

					this.thumbnailList.push({
						id: item._lastProgressCallback,
						url: img
					})
				})

				this.selectFileOrNot = true;
				this.selectFileShow = this.$refs.uploader.uploader.fileList.length < 9  ? true : false
			},
			fileRemoved(file){

				this.selectFileOrNot = false;
				this.selectFileShow = this.$refs.uploader.uploader.fileList.length < 9  ? true : false
				
			},
			fileUpload(){
				this.$refs.uploader.uploader.resume();
			},

			/*
			*
			* 上传资源
			 */
			fileSubmitRes( files, fileList, event) { 
			      if (files[0].size === 0) {
			      	this.$refs.uploaderRes.uploader.cancel();
			      	this.$message.error('上传文件大小不能小于0');
			      	this.selectFileShowRes = true
			      }else{
			      	this.selectFileShow = false 
			      	this.linkShowIco = false
			      	this.selectFileShowVideo = false 
			      }

			      if (fileList.length > 0) {
			      	this.selectFileBtn = false
			      }
			},
			//上传成功的事件  
			fileSuccessRes(rootFile, file, message, chunk) {
				this.uploadNumber++;
			    this.$refs.uploaderRes.uploader.cancel();
			    this.selectFileShow = true;
			    this.linkShowIco = true
			    this.selectFileShowVideo = true;
			    this.selectFileBtn = true
			    var mess = JSON.parse(message);
			    	mess = handleResponseData(mess)

			    	if (parseInt(mess.data.status) === 1) {
			    		this.resourceList.push({ 
			    		    name: mess.data.file_name, 
			    		    path: mess.data.file_path ,
			    		    postfix: mess.data.post_fix,
			    		})

			    	} else if (mess.status === 'fail') {
			    		this.$message.error(mess.msg + ' ' + file.name)
			    		this.$refs.uploaderRes.uploader.cancel()
			    	}

			},
			fileFailRes(rootFile, file, message, chunk) {
			    var mess = JSON.parse(message);
			    if (parseInt(mess.error) === 401 && this.uploadRetryTimesRes > 0) {
			        let callbcak = (data => {
			            this.uploadRetryTimesRes--;
			            this.$refs.uploaderRes.uploader.retry(file);
			        })
			        this.get_access_token(callbcak);
			    } else {
			        this.$message.error(mess.msg);
			    }
			},
			fileRemovedRes(file){
				this.selectFileShow = true;
				this.linkShowIco = true
				this.selectFileShowVideo = true;
				this.selectFileBtn = true
			},
			closeResource(index){
				this.resourceList.splice(index, 1)
			},
			fileUploadRes(){
				this.$refs.uploaderRes.uploader.resume();
			},

			/*
			* 视频上传
			 */
			fileAddVideo(file) { },
			//上传成功的事件  
			fileSuccessVideo(rootFile, file, message, chunk) {
			    this.$refs.uploaderVideo.uploader.cancel();
				this.uploadNumber++;
			    var mess = JSON.parse(message);
			    	mess = handleResponseData(mess)

			    	if (parseInt(mess.data.status) === 1) {
			    		this.resourceList.push({ 
			    			name: mess.data.file_name, 
			    			path: mess.data.file_path ,
			    			postfix: mess.data.post_fix,
			    			video: true
			    		})

			    	} else if (mess.status === 'fail') {
			    		this.$message.error(mess.msg + ' ' + file.name)
			    		this.$refs.uploaderVideo.uploader.cancel()
			    	}


			},
			fileFailVideo(rootFile, file, message, chunk) {
			    var mess = JSON.parse(message);
			    if (parseInt(mess.error) === 401 && this.uploadRetryTimesVideo > 0) {
			        let callbcak = (data => {
			            this.uploadRetryTimesVideo--;
			            this.$refs.uploaderVideo.uploader.retry(file);
			        })
			        this.get_access_token(callbcak);
			    } else {
			        this.$message.error(mess.msg);
			    }
			  
			},
			//过滤文件格式
			fileSubmitVideo(files, fileList, event){

				for (var i = 0 ; i < fileList.length ; i++ ) {
					var ext = fileList[i].name.split('.').pop();
					var file_type = fileList[i].fileType;
					if( file_type != 'video/mp4' && file_type != 'video/Ogg' && ext != 'rmvb' && file_type != 'video/x-matroska' && file_type != 'video/quicktime'){
						this.$message.warning('只支持上传mp4，Ogg， mov, rmvb格式视频')
						this.$refs.uploaderVideo.uploader.removeFile( fileList[i] );
					}else if( fileList[i].size >  this.uploadLimitMax*1024*1024  && this.uploadLimitMax > 0 ){
						this.$message.warning('只允许上传'+this.uploadLimitMax+'M以内的文件');
						this.$refs.uploaderVideo.uploader.removeFile( fileList[i] );
					}
					
					
				}
				
			},

		}
	}
</script>
<style type="text/css">
.classCircle .el-dialog__wrapper {
	text-align: center;
}

.checkHide {
	display: none;
}
</style>